game_manager
{

	spawn
	{
	
/////////////////////////Street bugfix///////////////////////
		create
		{
			scriptName "bugfix1"
			classname "func_fakebrush"
			origin "4534 8019 -266" //-266
			contents "1"  // CONTENTS_SOLID
			clipmask "67108864" 
			mins "-180 -150 -10"
			maxs "180 150 10"
		}
		
/////////////////////////Wall bugfix///////////////////////
		create
		{
			scriptName "bugfix2"
			classname "func_fakebrush"
			origin "1073 8450 -20"  //1080
			contents "1"  // CONTENTS_PLAYERCLIP
			mins "-17 -130 -12"
			maxs "15 126 20"
		}
		
//////////////////////cp spawn//////////////////////////////////
		create
		{
			classname "team_WOLF_objective"
			scriptname "cps_obj"
			targetname "cps_obj"
			origin "1971 1806 102"   // z = CC_FILTER_ALLIES(1) | CC_FILTER_SPAWNS(4)
			spawnflags "2"	 // TEAM_AXIS(3) TEAM_ALLIES (2)
			description "Bridge Cp Spawn"
		}
		create
		{
  		 	scriptName "cps_spawn1"
   			classname "team_CTF_bluespawn"
  			targetname "cps_spawn"
   			origin "2066 1765 50"
			angle "180"
   			spawnflags 1   // TEAM_ALLIES
		}

		create
		{
  			scriptName "cps_spawn2"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2067 1809 50"
			angle "180"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn3"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2067 1881 50"
			angle "180"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn4"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "1994 1959 50"
			angle "-90"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn5"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "1918 1956 50"
			angle "-90"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn6"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2173 1460 256"
			angle "0"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn7"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
  			origin "2178 1710 256"
			angle "0"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn8"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2173 1585 256"
			angle "-90"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn9"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2260 1790 256"
			angle "-90"
   			spawnflags 1   // TEAM_ALLIES
		}
		create
		{
  			scriptName "cps_spawn10"
   			classname "team_CTF_bluespawn"
   			targetname "cps_spawn"
   			origin "2372 1790 256"
			angle "-90"
   			spawnflags 1   // TEAM_ALLIES
		}

		accum 1 set 0		
		accum 5 set 0		
		accum 6 set 0		
		accum 7 set 0		

		globalaccum 5 set 0
		globalaccum 6 set 0

		// Game rules
		wm_axis_respawntime	30
		wm_allied_respawntime	20
		wm_number_of_objectives 7
		wm_set_round_timelimit	20

		// Objectives
		// 1: Primary1 : Destroy the Main Gate
		// 2: Primary2 : Destroy the East Tank
		// 3: Primary3 : Destroy the West Tank
		// 4: Secondary1 : Destroy the Upper Wall
		// 5: Secondary2 : Capture forward spawn point
		// 6: Allied command post
		// 7: Axis command post

		// Current main objectives for each team (0=Axis, 1=Allies)
		wm_set_main_objective		2	0
		wm_set_main_objective		2	1

		// Objective overview status indicators
		//wm_objective_status <objective> <team (0=Axis, 1=Allies)> <status (0=neutral 1=complete 2=failed)>
		wm_objective_status 1 1 0
		wm_objective_status 1 0 0
		wm_objective_status 2 1 0
		wm_objective_status 2 0 0
		wm_objective_status 3 1 0
		wm_objective_status 3 0 0
		wm_objective_status 4 1 0
		wm_objective_status 4 0 0
		wm_objective_status 5 1 0
		wm_objective_status 5 0 0
		wm_objective_status 6 1 0
		wm_objective_status 6 0 0
		wm_objective_status 7 1 0
		wm_objective_status 7 0 0


		// Stopwatch mode defending team (0=Axis, 1=Allies)
		wm_set_defending_team	0

		// If the round timer expires, the Axis have won, so set the current winning team
		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 0

		// Set autospawn markers <team (0 = axis, 1 = allies)> <message key of marker>
		// Spawns on Stalingrad:
		// Rear Spawn
		// Allied Camp
		// Damaged Munitions Depot
		wait 150

		setautospawn "Munitions Depot"		1
		setautospawn "Munitions Depot"		0

		wait 350
		construct mg42_clip_1
		construct mg42_clip_2
	}

	trigger tank_counter
	{
		accum 5 inc 1				// Increase game counter
		accum 5 abort_if_not_equal 2		// All guns destroyed ?

		wm_announce	"Allies have destroyed both tanks!"

		wait 1000

		accum 1 set 1				// Both tanks destroyed

		// Call function to check if the round has been won
		trigger game_manager checkgame
	}


	trigger checkgame
	{
		accum 1 abort_if_not_equal 1

		// Set the round winner:  0 == AXIS, 1 == ALLIED
		wm_setwinner 1

		// End the round
		wm_endround
	}

	trigger timelimit_hit
	{
		//trigger end_boom_north check_0
		//trigger end_boom_south check_1
		wait 50
		wm_setwinner 0
		wait 50
		wm_endround
	}
}

end_boom_north
{
}

end_boom_south
{
}

munitionsflag
{
	spawn
	{
		accum 0 set 0	// Who has the flag: 0-Axis, 1-Allied
		remove
	}

	trigger axis_capture	// Flag has been touched by an Axis player
	{
		accum 0 abort_if_equal 0 // do Axis own flag?

		accum 0 set 0 // Axis own the pole

		wm_objective_status 		5 0 1
		wm_objective_status 		5 1 2

		alertentity munitions_wobj
		setautospawn "Munitions Depot"	0
	}

	trigger allied_capture	// Flag has been touched by an allied player
	{
		accum 0 abort_if_equal 1 // do Allies own flag?

		accum 0 set 1 // Allied own the flag
		wm_announce	"Allies capture the Munitions Depot!"

		wm_objective_status 		5 0 2
		wm_objective_status 		5 1 1

		alertentity munitions_wobj
		setautospawn "Munitions Depot"	1
	}

	trigger check_obj
	{
		accum 0 abort_if_equal 1 // Do Allied own the flag?

		wm_objective_status 		5 0 2
		wm_objective_status 		5 1 1

	}

	trigger force_allied
	{
		accum 0 abort_if_equal 1 // Do Allied own the flag?

		alertentity munitions_wobj
		alertentity munitionspawns
	}

	trigger kill
	{
		remove
	}
}

upperwall //Broken section of Upper wall
{
	spawn
	{
		wait 200
	set
		{
		constructible_class 1
		health "20"
		}
	}

	death
	{
	}

}

maingate //The Main Gate
{
	spawn
	{
		wait 200

	set
		{
		constructible_class 1
		health "20"
		}
	}

	death
	{
		trigger munitionsflag force_allied

		trigger munitionsflag check_obj

		trigger munitionsflag kill

	}

}

// North Tank
northtank
{
	spawn
	{
		wait 200

		constructible_class 3

		trigger northtank setup
	}

	trigger setup
	{
		setstate northtank_smoke_1 invisible
		setstate northtank_destroyed invisible
		
		setstate northtank default
	}

	death
	{
		setstate northtank_smoke_1 default
		setstate northtank_destroyed default
		
		setstate northtank invisible

		wm_announce "Allies have destroyed the East Tank!"

		wm_objective_status 		1 0 2
		wm_objective_status 		1 1 1

		wm_set_main_objective	2 0
		wm_set_main_objective	2 1

		trigger game_manager tank_counter
	}
}

// South Tank
southtank
{
	spawn
	{
		wait 200

		constructible_class 3

		trigger southtank setup
	}

	trigger setup
	{
		setstate southtank_smoke_1 invisible
		setstate southtank_destroyed invisible
		
		setstate southtank default
	}

	death
	{
		setstate southtank_smoke_1 default
		setstate southtank_destroyed default
		
		setstate southtank invisible

		wm_announce "Allied team has destroyed the West Tank!"

		wm_objective_status 		2 0 2
		wm_objective_status 		2 1 1

		// Update game manager counter for objectives
		trigger game_manager tank_counter
	}
}

// ================================================
// ======== END DESTRUCTIBLE STUFF ================
// ================================================


// ================================================
// =============== COMMAND POSTS ==================
// ================================================

allied_radio_destroyed
{
	spawn
	{
		wait 400
		setstate allied_radio_destroyed invisible
		setstate allied_radio_destroyed_model invisible
	}

	trigger hide
	{
		setstate allied_radio_destroyed invisible
		setstate allied_radio_destroyed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 0
		setstate allied_radio_destroyed default
		setstate allied_radio_destroyed_model default
	}

	trigger enable
	{
		accum 0 set 1
	}
}

allied_radio_closed
{
	trigger hide
	{
		setstate allied_radio_closed invisible
		setstate allied_radio_closed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate allied_radio_closed default
		setstate allied_radio_closed_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

allied_radio_built
{
	spawn
	{
		wait 400

		constructible_class 2

		trigger allied_radio_built setup
		setstate cps_obj invisible
		setstate cps_spawn invisible
	}

	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0
	}

	buildstart final
	{
		trigger allied_radio_built_model trans

		trigger allied_radio_destroyed hide
		trigger allied_radio_closed 	hide
	}

	built final
	{
		trigger allied_radio_built_model show

		trigger allied_radio_destroyed enable
		trigger allied_radio_closed 	disable

		alertentity cps_spawn
		setstate cps_obj default
		setstate cps_spawn default
		//setautospawn "Bridge Cp Spawn"	1

		trigger allied_radio_built_model enable_allied_features

		enablespeaker allies_compost_sound
	}

	decayed final
	{
		trigger allied_radio_built_model hide

		trigger allied_radio_destroyed show
		trigger allied_radio_closed 	show
	}

	death
	{
		trigger allied_radio_built_model hide

		trigger allied_radio_destroyed show

		trigger allied_radio_built_model disable_allied_features

		disablespeaker allies_compost_sound
		
		//alertentity allied_spawn_wobj
		alertentity cps_spawn
		
		setstate cps_obj invisible
		setstate cps_spawn invisible
		//setautospawn "Allied River Spawn"	1
	}
}

allied_radio_built_model
{
	spawn
	{
		wait 400
		setstate allied_radio_built_model invisible
	}

	trigger show
	{
		setstate allied_radio_built_model default
	}

	trigger hide
	{
		setstate allied_radio_built_model invisible
	}

	trigger trans
	{
		setstate allied_radio_built_model underconstruction
	}

	trigger enable_allied_features
	{
		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"Allied Command Post constructed. Charge speed increased!"

		wm_objective_status 6 1 1
		wm_objective_status 6 0 2

	}

	trigger disable_allied_features
	{
		// Some kind of UI pop-up to alert players
		wm_announce	"Axis team has destroyed the Allied Command Post!"

		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0

		wm_objective_status 6 1 0
		wm_objective_status 6 0 0
	}
}

axis_radio_destroyed
{
	spawn
	{
		wait 400
		setstate axis_radio_destroyed invisible
		setstate axis_radio_destroyed_model invisible
	}

	trigger hide
	{
		setstate axis_radio_destroyed invisible
		setstate axis_radio_destroyed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 0
		setstate axis_radio_destroyed default
		setstate axis_radio_destroyed_model default
	}

	trigger enable
	{
		accum 0 set 1
	}
}

axis_radio_closed
{
	trigger hide
	{
		setstate axis_radio_closed invisible
		setstate axis_radio_closed_model invisible
	}

	trigger show
	{
		accum 0 abort_if_equal 1
		setstate axis_radio_closed default
		setstate axis_radio_closed_model default
	}

	trigger disable
	{
		accum 0 set 1
	}
}

axis_radio_built
{
	spawn
	{
		wait 400

		constructible_class 2

		trigger axis_radio_built setup
	}

	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0
	}

	buildstart final
	{
		trigger axis_radio_built_model trans

		trigger axis_radio_destroyed hide
		trigger axis_radio_closed 	hide
	}

	built final
	{
		trigger axis_radio_built_model show

		trigger axis_radio_destroyed enable
		trigger axis_radio_closed 	disable

		trigger axis_radio_built_model enable_axis_features

		enablespeaker axis_compost_sound
	}

	decayed final
	{
		trigger axis_radio_built_model hide

		trigger axis_radio_destroyed show
		trigger axis_radio_closed 	show
	}

	death
	{
		trigger axis_radio_built_model hide

		trigger axis_radio_destroyed show

		trigger axis_radio_built_model disable_axis_features

		disablespeaker axis_compost_sound
	}
}

axis_radio_built_model
{
	spawn
	{
		wait 400
		setstate axis_radio_built_model invisible
	}

	trigger show
	{
		setstate axis_radio_built_model default
	}

	trigger hide
	{
		setstate axis_radio_built_model invisible
	}

	trigger trans
	{
		setstate axis_radio_built_model underconstruction
	}

	trigger enable_axis_features
	{
		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"Axis Command Post constructed. Charge speed increased!"

		wm_objective_status 7 1 2
		wm_objective_status 7 0 1

	}

	trigger disable_axis_features
	{
		// Some kind of UI pop-up to alert players
		wm_announce	"Allied team has destroyed the Axis Command Post!"

		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0

		wm_objective_status 7 1 0
		wm_objective_status 7 0 0
	}
}


axis_command_post_lms_toi
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_lms_closed
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_lms_destroyed
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_built_lms
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_closed_lms_model
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_destroyed_lms_model
{
	spawn
	{
		wait 400

		remove
	}
}

axis_radio_built_lms_model
{
	spawn
	{
		wait 400

		remove
	}
}

axis_command_post_clip_lms
{
	spawn
	{
		wait 400

		remove
	}
}
// ===================================================
// ============== END COMMAND POSTS ==================
// ===================================================

// ===================================================
// ================ START MG NEST ====================
// ===================================================

mg42_clip_1
{
	spawn
	{
		wait 200

		constructible_class 2

		trigger mg42_clip_1 setup
	}

	trigger setup
	{
		setstate mg42_1 invisible

		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default
	}

	buildstart final
	{
		setstate mg42_1 underconstruction

		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default
	}

	built final
	{
		setstate mg42_1 default

		setstate mg42_materials_1 invisible
		setstate mg42_materials_clip_1 invisible
		setstate mg42_flag_1 invisible

	}

	death
	{
		setstate mg42_1 invisible
		repairmg42 mg42_1
		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default

		wm_announce	"The East Tank MG Nest has been damaged!"
	}

	decayed final
	{
		setstate mg42_1 invisible

		setstate mg42_materials_1 default
		setstate mg42_materials_clip_1 default
		setstate mg42_flag_1 default
	}
}

mg42_clip_2
{
	spawn
	{
		wait 200

		constructible_class 2

		trigger mg42_clip_2 setup
	}

	trigger setup
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	buildstart final
	{
		setstate mg42_2 underconstruction

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}

	built final
	{
		setstate mg42_2 default

		setstate mg42_materials_2 invisible
		setstate mg42_materials_clip_2 invisible
		setstate mg42_flag_2 invisible

	}

	death
	{
		setstate mg42_2 invisible
		repairmg42 mg42_2
		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default

		wm_announce	"The West Tank MG Nest has been damaged!"
	}

	decayed final
	{
		setstate mg42_2 invisible

		setstate mg42_materials_2 default
		setstate mg42_materials_clip_2 default
		setstate mg42_flag_2 default
	}
}
// ===================================================
// ================= END MG NEST =====================
// ===================================================